package huisu.onClass.class02.exer01;

import java.util.Scanner;

public class Main {

    private static boolean success = false;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        while (k > 0) {
            success = false;
            int n = sc.nextInt();
            char[][] mat = new char[n][n];
            for (int i = 0; i < n; i++) {
                String line = sc.next();
                for (int j = 0; j < n; j++) {
                    mat[i][j] = line.charAt(j);
                }
            }
            int ar = sc.nextInt(), ac = sc.nextInt();
            int br = sc.nextInt(), bc = sc.nextInt();
            int[][] nextPos = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
            boolean[][] flag = new boolean[n][n];
            if (mat[ar][ac] == '#') {
                System.out.println("NO");
            } else {
                dfs(ar, ac, n, n, nextPos, mat, flag, br, bc);
                if (success) {
                    System.out.println("YES");
                } else {
                    System.out.println("NO");
                }
            }
            k--;
        }
    }

    public static void dfs(int curRow, int curCol, int rows, int cols, int[][] nextPos, char[][] mat, boolean[][] flag, int endRow, int endCol) {
        if (curRow == endRow && curCol == endCol) {
            success = true;
            return;
        }
        flag[curRow][curCol] = true;
        for (int i = 0; i < 4; i++) {
            int nextRow = curRow + nextPos[i][0];
            int nextCol = curCol + nextPos[i][1];
            if (nextRow >= 0 && nextRow < rows && nextCol >= 0 && nextCol < cols && !flag[nextRow][nextCol] && mat[nextRow][nextCol] == '^') {
                dfs(nextRow, nextCol, rows, cols, nextPos, mat, flag, endRow, endCol);
            }
        }
        flag[curRow][curCol] = false;
    }
}
